<?php
/**
 * This file is part of webman.
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the MIT-LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @author    walkor<walkor@workerman.net>
 * @copyright walkor<walkor@workerman.net>
 * @link      http://www.workerman.net/
 * @license   http://www.opensource.org/licenses/mit-license.php MIT License
 */

use Webman\Route;

// 无需令牌能访问的路由  登录  刷新  测试
Route::group("/api/admin", function() {
    Route::post("/login", [\app\Http\Controllers\Admin\LoginController::class, "login"])
        ->name("admin.login");
    Route::post("/refresh", [\app\Http\Controllers\Admin\LoginController::class, "refresh"])
        ->name("admin.refresh");
    Route::get("/test", [\app\Http\Controllers\Admin\LoginController::class, "test"])
        ->name("admin.test");
    Route::post("/captcha", [\app\Http\Controllers\Admin\LoginController::class, "captcha"])
        ->name("admin.captcha");
    Route::post("/check_captcha", [\app\Http\Controllers\Admin\LoginController::class, "check_captcha"])
        ->name("admin.check_captcha");

});

// 需要登录才能访问的接口，中间件查询
Route::group("/api/admin", function() {
    Route::get("/me", [\app\Http\Controllers\Admin\LoginController::class, "me"])
        ->name("admin.me");
    Route::post("/logout", [\app\Http\Controllers\Admin\LoginController::class, "logout"])
        ->name("admin.logout");
    Route::post("/media", [\app\Http\Controllers\Admin\MediaController::class, "upload"])
        ->name("media.upload");  // 媒体文件上传
    Route::post("/upload_img", [\app\Http\Controllers\Admin\MediaController::class, "uploadImg"])
        ->name("media.upload_img");  // 图像上传
})->middleware([
    \app\middleware\AdminAuthUser::class
]);


// 需要获得角色授权的接口 仅需要令牌，还需要去授权的路由  各种管理业务
Route::group("/api/admin", function() {

//  Route::resource('/admins', app\admin\controller\AdminController::class,
//      ['index','show', "store", "update", "destroy"]);

})->middleware([
    \app\middleware\AdminAuthUser::class
]);



// 只需令牌能访问的路由 获取个人信息 上传文件 退出